package com.ruoyi.erp.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.erp.mapper.BusinessUnitMapper;
import com.ruoyi.erp.domain.BusinessUnit;
import com.ruoyi.erp.service.IBusinessUnitService;
import com.ruoyi.common.core.text.Convert;

/**
 * 事业部Service业务层处理
 * 
 * @author sauger
 * @date 2022-03-14
 */
@Service
public class BusinessUnitServiceImpl implements IBusinessUnitService 
{
    @Autowired
    private BusinessUnitMapper businessUnitMapper;

    /**
     * 查询事业部
     * 
     * @param id 事业部主键
     * @return 事业部
     */
    @Override
    public BusinessUnit selectBusinessUnitById(Integer id)
    {
        return businessUnitMapper.selectBusinessUnitById(id);
    }

    /**
     * 查询事业部列表
     * 
     * @param businessUnit 事业部
     * @return 事业部
     */
    @Override
    public List<BusinessUnit> selectBusinessUnitList(BusinessUnit businessUnit)
    {
        return businessUnitMapper.selectBusinessUnitList(businessUnit);
    }

    /**
     * 新增事业部
     * 
     * @param businessUnit 事业部
     * @return 结果
     */
    @Override
    public int insertBusinessUnit(BusinessUnit businessUnit)
    {
        businessUnit.setCreateTime(DateUtils.getNowDate());
        return businessUnitMapper.insertBusinessUnit(businessUnit);
    }

    /**
     * 修改事业部
     * 
     * @param businessUnit 事业部
     * @return 结果
     */
    @Override
    public int updateBusinessUnit(BusinessUnit businessUnit)
    {
        businessUnit.setUpdateTime(DateUtils.getNowDate());
        return businessUnitMapper.updateBusinessUnit(businessUnit);
    }

    /**
     * 批量删除事业部
     * 
     * @param ids 需要删除的事业部主键
     * @return 结果
     */
    @Override
    public int deleteBusinessUnitByIds(String ids)
    {
        return businessUnitMapper.deleteBusinessUnitByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除事业部信息
     * 
     * @param id 事业部主键
     * @return 结果
     */
    @Override
    public int deleteBusinessUnitById(Integer id)
    {
        return businessUnitMapper.deleteBusinessUnitById(id);
    }
}
